package cn.cdiothree.service.impl;

import cn.cdiothree.dao.CarouselMapper;
import cn.cdiothree.dataobject.Carousel;
import cn.cdiothree.service.CarouselService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品轮播图
 */
@Service
@Slf4j
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements CarouselService {
    @Autowired
    private CarouselMapper carouselMapper;

    /**
     * 根据商品id查找图片
     * @param productId
     * @return
     */
    @Override
    public List<Carousel> findByProductId(Integer productId){
        log.info("查找{}商品图片",productId);
        QueryWrapper<Carousel> wrapper = new QueryWrapper<>();
        wrapper.eq("product_id",productId);
        List<Carousel> carousel =  carouselMapper.selectList(wrapper);
        return carousel;
    }
}
